home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / dev / e / doomwad.lha / Examples / WADdir.e < prev   
Text File  |  1998-03-15  |  2KB  |  64 lines

  1. /*
  2. ** WADDir
  3. **
  4. ** Shows all the lumps in a given .WAD
  5. **
  6. ** WARNING: The commercial wads contain bloody loads of lumps, and WADDir
  7. ** has been known to crash if you leave it for too long on a commercial one.
  8. */
  9.  
  10. MODULE 'doomwad'
  11.  
  12. PROC main()
  13.   DEF mwh:PTR TO wadhandle, mdb:dirblock, c
  14.   
  15.   /* No wad specified? */
  16.   IF(StrCmp(arg,''))
  17.     WriteF('WADdir ©1998 Mr Tickle/dNT\n\nUsage: WADdir <filename>.WAD\n')
  18.   ELSE
  19.   
  20.     /* Open the wad */
  21.     IF(mwh:=openwad(arg))
  22.       
  23.       /* Tell the user what sort of wad it is ... */
  24.       WriteF('It is')
  25.       IF(mwh.iwad=FALSE) THEN WriteF('n\at')
  26.       WriteF(' an IWAD\n')
  27.       
  28.       /* ... how many lumps it has ... */
  29.       WriteF('Number of lumps: \d\n',mwh.numlumps)
  30.       
  31.       /* ... where the directory is and ... */
  32.       WriteF('Dir is at: \h\n',mwh.dirstrt)
  33.       
  34.       /* All the lumps :) */
  35.       WriteF('\nDirectory:\n')
  36.       
  37.       /* Loop through all the lumps */
  38.       FOR c:=0 TO mwh.numlumps-1
  39.       
  40.         /* Read entry C into mdb */
  41.         readentry(c*16,mwh,mdb)
  42.         
  43.         /* If its size is larger than 0, its a proper lump, otherwise its
  44.         ** just a level marker */
  45.         
  46.         IF(mdb.size>0)
  47.           WriteF('\l\s[8]  \r\z\h[8]  \z\h[8]\n',mdb.name,mdb.offset,mdb.size)
  48.         ELSE
  49.           WriteF('  \e[32m\s\e[0m\n',mdb.name)
  50.         ENDIF
  51.         
  52.         /* Check for CtrlC() */
  53.         IF(CtrlC())
  54.           WriteF('***BREAK\n')
  55.           c:=mwh.numlumps-1
  56.         ENDIF
  57.       ENDFOR
  58.       
  59.       /* Close the wad */
  60.       closewad(mwh)
  61.     ENDIF
  62.   ENDIF
  63. ENDPROC
  64.